<template>
  <div class="login-bg">
    <div class="login-container">
      <img class="login-logo" src="@/assets/logo.png" alt="logo" />
      <div class="login-title">生鲜电商·后台系统</div>
      <el-form class="login-form">
        <el-form-item>
          <el-input
            v-model="loginForm.administratorPhone"
            placeholder="请输入手机号"
            class="login-input"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="loginForm.administratorPassword"
            type="password"
            placeholder="请输入密码"
            class="login-input"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button class="login-btn" type="primary" @click="login">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
    <svg class="wave" viewBox="0 0 1440 120" xmlns="http://www.w3.org/2000/svg">
      <path fill="none" stroke="#fff" stroke-width="2"
        d="M0,80 C360,160 1080,0 1440,80" />
      <path fill="none" stroke="#fff" stroke-width="2" opacity="0.5"
        d="M0,100 C480,0 960,200 1440,100" />
    </svg>
  </div>
</template>

<script>
export default {
  data() {
    return {
     loginForm: {
      phone: '',
      password: ''
     }
    }
  },
  methods: {
    login() {
        //登录逻辑
        if(this.loginForm.administratorPhone === '' || this.loginForm.administratorPassword === '') {
            this.$message.error('请输入手机号和密码');
            return;
        }
        //调用登录接口
        this.$axios.post('/api/user/Backlogin', this.loginForm).then(res => {
            if(res.data.code === 200) {
                this.$message.success('登录成功');
                console.log(res.data.data);
                //带参数跳转
                this.$router.push({path: '/index', query: {administratorId: res.data.data.administratorId}});
            } else {
                this.$message.error('登录失败');
            }
        })
      
    }
  }
}
</script>

<style scoped>
.login-bg {
  min-height: 100vh;
  background: #08a6c3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 60px;
}
.login-logo {
  width: 180px;
  margin-bottom: 30px;
}
.login-title {
  color: #fff;
  font-size: 38px;
  font-weight: 500;
  margin-bottom: 40px;
  text-align: center;
  letter-spacing: 2px;
}
.login-form {
  width: 350px;
}
.login-input >>> .el-input__inner {
  background: transparent;
  border: 1.5px solid #fff;
  color: #fff;
  border-radius: 6px;
  height: 44px;
  font-size: 16px;
  text-align: center;
}
.login-input >>> .el-input__inner::placeholder {
  color: #fff;
  opacity: 0.8;
}
.login-btn {
  width: 100%;
  background: #fff !important;
  color: #08a6c3 !important;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 500;
  border: none;
  margin-top: 10px;
}
.wave {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100vw;
  height: 120px;
  z-index: 1;
}
</style>